package leetcode.code0869;

import java.util.HashSet;
import java.util.Set;

public class Solution extends Solution869 {

	static Set<String> table;

	static {
		table = new HashSet<>();
		int n = 1;
		while (n < 1000000000) {
			table.add(num2str(n));
			n <<= 1;
		}
	}

	static String num2str(int num) {
		int[] temp = new int[10];
		while (num > 0) {
			int mod = num % 10;
			temp[mod]++;
			num /= 10;
		}
		StringBuffer key = new StringBuffer();
		for (int i = 0; i < 10; i++) {
			key.append(temp[i]).append('-');
		}
		return key.toString();
	}

	@Override
	public boolean reorderedPowerOf2(int n) {
		String key = num2str(n);
		return table.contains(key);
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		so.debug5();
	}

}
